﻿using Autofac.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace AutoFacPack
{
    public class PropertySelector : IPropertySelector
    {
        private Type Type { get; set; }
        public PropertySelector(Type type) 
        {
            this.Type = type;
        }
        public PropertySelector()
        {
        }
        bool IPropertySelector.InjectProperty(PropertyInfo propertyInfo, object instance)
        {
            //if (this.Type!=null&&propertyInfo.PropertyType.GetInterface(this.Type.Name)!=null)
            //{
            //    return false;
            //}


            BindingFlags flag = BindingFlags.NonPublic | BindingFlags.Instance;
            Type type = instance.GetType();
            PropertyInfo field = type.GetProperty(propertyInfo.Name, flag);
            if (field == null)
            {
                return false;
            }
            return true;
        }
    }
}
